package com.mnt.washio.views;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.mnt.washio.R;

public class CongraDialog extends Dialog {
	public static int ACCOUNT = 0;
	public static int ADDRESS = 1;
	public static int CARD = 2;
	public static int ORDER = 3;

	private Context ctx;
	private int type;
	private ImageView mImvCongrats;

	public CongraDialog(Context context, int type) {
		super(context, android.R.style.Theme_Light_NoTitleBar_Fullscreen);
		this.ctx = context;
		this.type = type;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		LayoutInflater mInflater = (LayoutInflater) ctx
				.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
		View view = mInflater.inflate(R.layout.layout_congratulation,
				null);
		mImvCongrats = (ImageView)view.findViewById(R.id.imv_congrats);

		initImage();
		setContentView(view);

	}

	public void initImage() {
		if (mImvCongrats == null)
			return;
		switch (type) {
		case 0:
			mImvCongrats.setImageResource(R.drawable.hero_account);
			break;
		case 1:
			mImvCongrats.setImageResource(R.drawable.hero_address);
			break;
		case 2:
			mImvCongrats.setImageResource(R.drawable.hero_card);
			break;
		case 3:
			mImvCongrats.setImageResource(R.drawable.hero_order);
			break;
		}
	}

	@Override
	public void show() {
		new CountDownTimer(1500, 1500) {

			@Override
			public void onTick(long arg0) {
			}

			@Override
			public void onFinish() {
				dismiss();
			}
		}.start();
		
		super.show();
	}
	
	@Override
	public void dismiss() {
		onDissmis();
		super.dismiss();
	}
	
	public void onDissmis(){};
}
